<?php if(!defined('BASEPATH'))exit('No direct script access allowed'); ?>
<?php $this->load->view('admin/global/header'); ?>
<?php $this->load->view('admin/global/left'); ?>
<table cellpadding="0" cellspacing="0">
    <tr>
        <td class="title"><?php if(isset($news)){echo lang('EDIT').': '.lang('NEWS');}else{echo lang('POST').': '.lang('NEWS');} ?></td>
    </tr>
    <?php if(isset($denied)){ ?>
    <tr>
        <td class="bar">
            <div class="error"><?php echo lang('DENIED'); ?></div>
            <meta http-equiv="refresh" content="5; <?php echo base_url().ADMIN_PATH; ?>" />
        </td>
    </tr>
    <?php }else{ ?>
    <?php if($success == true){ ?>
    <tr>
        <td class="bar">
            <div class="success"><?php echo lang('SUCCESS_UPDATED_DATA'); ?></div>
            <meta http-equiv="refresh" content="1" />
        </td>
    </tr>
    <?php }else{ ?>
    <?php echo Modules::run('admin/bar_module/index', $buttons); ?>
    <tr>
        <td valign="top">
        <form name="frmPost" id="frmPost" method="post" enctype="multipart/form-data">
            <table class="form" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="label"><span class="red">*</span> <?php echo lang('TITLE'); ?>:</td>
                    <td>
                        <input type="text" name="txtTitle" class="input" value="<?php if(isset($news)){echo set_value('txtTitle', $news->newTitle);}else{echo set_value('txtTitle');} ?>" />
                        <?php echo form_error('txtTitle'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><span class="red">*</span> <?php echo lang('SECTION'); ?></td>
                    <td>
                        <select name="txtSection" id="txtSection" class="select" style="width:150px;">
                            <?php foreach($sections as $section){ ?>
                            <option value="<?php echo $section->secID; ?>" <?php if(isset($news) && (int)$news->newSection == (int)$section->secID){echo set_select('txtSection', $section->secID, true);}else{echo set_select('txtSection', $section->secID);} ?>><?php echo $section->secName; ?></option>
                            <?php } ?>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="label"><span class="red">*</span> <?php echo lang('CATEGORY'); ?></td>
                    <td>
                        <!--BEGIN: Choise Category-->
                        <script>
                            <?php $index = 0; ?>
                            <?php foreach($categories as $category){ ?>
                            category[<?php echo $index++; ?>] = new set('<?php echo $category->catSection; ?>', '<?php echo $category->catID; ?>', '<?php echo $category->catName; ?>', '<?php if(isset($news) && (int)$news->newCategory == (int)$category->catID){echo set_select('txtCategory', $category->catID, true);}else{echo set_select('txtCategory', $category->catID);} ?>');
                            <?php } ?>
                            $(document).ready(function(){$().eChoise();});
                        </script>
                        <!--END Choise Category-->
                        <select name="txtCategory" id="txtCategory" class="select" style="width:150px;"></select>
                    </td>
                </tr>
                <tr>
                    <td class="labelEditor"><span class="red">*</span> <?php echo lang('DETAIL'); ?></td>
                    <td>
                        <script language="javascript" src="<?php echo base_url(); ?>templates/editor/tiny_mce.js"></script>
                        <script language="javascript" src="<?php echo base_url(); ?>templates/admin/js/editor.js"></script>
                        <textarea name="txtDetail" id="txtDetail" class="textEditor"><?php if(isset($news)){echo set_value('txtDetail', $news->newDetail);}else{echo set_value('txtDetail');} ?></textarea>
                        <?php echo form_error('txtDetail'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><?php echo lang('IMAGE'); ?>:</td>
                    <td>
                        <input type="file" name="txtImage" />
                        <?php if(isset($news)){ ?>
                        <img src="<?php echo base_url(); ?>templates/admin/images/expand.png" class="tip vtip" title="<?php echo tip(base_url().show_thumbnail('thumbnail135X101_', $news->newImage, IMAGE_PATH.'news/'.$news->newDirImage.'/'), true); ?>" align="top" style="margin-top:4px;" />
                        <?php } ?>
                        <img src="<?php echo base_url(); ?>templates/admin/images/tip.jpg" class="tip vtip" title="<?php echo lang('IMAGE_NEWS_TIP'); ?>" align="top" />
                    </td>
                </tr>
                <tr>
                    <td class="label0"><?php echo lang('ACTIVE'); ?>:</td>
                    <td>
                        <input type="checkbox" name="txtStatus" class="checkbox" value="1" <?php if(isset($news) && (int)$news->newStatus == 1){echo set_checkbox('txtStatus', 1, true);}else{echo set_checkbox('txtStatus', 1);} ?> />
                    </td>
                </tr>
            </table>
        </form>
        </td>
    </tr>
    <?php } ?>
    <?php } ?>
</table>
<?php $this->load->view('admin/global/right'); ?>
<?php $this->load->view('admin/global/footer'); ?>